/*
* Copyright (C) 2023 ~ 2033 Ltd.
*
* Author:     helei <2454264168@qq.com>
*
* Maintainer: helei <2454264168@qq.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* General Public License version 3 as published by the Free Software
* Foundation and appearing in the file LICENSE.MIT included in the
* packaging of this file.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USCROLLBAR_H
#define USCROLLBAR_H

#include "utkwidget_export.h"
#include "style/uproxystyle.h"

#include <QScrollBar>
#include <QPropertyAnimation>


class UTKWIDGET_EXPORT UScrollBar : public QScrollBar
{
    Q_OBJECT
    Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
public:
    explicit UScrollBar(QWidget* parent = nullptr);
    explicit UScrollBar(Qt::Orientation, QWidget* parent = nullptr);

    qreal opacity() const;

    void setOpacity(qreal opacity);

signals:
    void opacityChanged();

protected:
    void paintEvent(QPaintEvent*) override;
    void enterEvent(QEvent* event) override;
    void leaveEvent(QEvent* event) override;

private:
    void initAnimation();
    void handleAnimation(qreal startValue, qreal endValue);
    QPropertyAnimation m_propertyAnimation;
    qreal m_opacity = 0.0;
    QScopedPointer<UProxyStyle> m_style;
};

#endif // USCROLLBAR_H
